<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>Promise-111</div>
  </body>
  <script>
    // function executor(resolve, reject) {
    //   let rand = Math.random()
    //   console.log(1)
    //   console.log('rand==', rand)
    //   if (rand > 0.5) resolve()
    //   else reject(`${rand}小于了0.5`)
    // }
    // let p0 = new Promise(executor)
    // let p1 = p0.then((res) => {
    //   console.log('success--1')
    //   return new Promise(executor)
    // })
    // let p2 = p1.then((res) => {
    //   console.log('success--2')
    //   return new Promise(executor)
    // })
    // let p3 = p2.then((res) => {
    //   console.log('success--3')
    //   return new Promise(executor)
    // })
    // p3.catch((error) => {
    //   console.log('error==', error)
    // })

    // let p1 = new Promise((resolve, reject) => {
    //   resolve(200)
    // })
    // let p2 = p1.then((res) => {
    //   console.log(res)
    //   return Promise.reject('error==')
    // })
    // console.log(p2)
    let p3 = new Promise((resolve, reject) => {
      reject('error2==')
    })
    let p4 = p3.catch((error) => console.log(error))
    console.log('p4===', p4)
    p4.then(
      (res) => {
        console.log('p3的回调resolve', res)
      },
      (err) => {
        console.log('p3的回调reject', err)
      }
    )
    // console.log(p3)
    // try {
    //   p3.then
    // }
  </script>
</html>
